import {fileURLToPath, URL} from 'node:url'

import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'

// https://vite.dev/config/
export default defineConfig({
    plugins: [
        vue(),
        vueDevTools(),
    ],
    resolve: {
        alias: {
            '@': fileURLToPath(new URL('./src', import.meta.url))
        },
    },
    // vite 相关配置
    server: {
        port: 88,
        host: true,
        open: true,
        proxy: {
            // https://cn.vitejs.dev/config/#server-proxy
            '/dev-api': {
                target: 'http://localhost:8080',
                // target: 'http://192.168.10.40:8181',//工作室
                // target: 'http://10.141.27.148:8181',//巴拉素外网
                changeOrigin: true,
                ws: false,
                rewrite: (p) => p.replace(/^\/dev-api/, '')
            }
        }
    },
    css: {
        preprocessorOptions: {
            scss: {api: 'modern-compiler'},
        }
    }
})
